﻿@model EquationsBankSite.Models.FieldsModel
@{
    var titleNode = Model.CategoryTree.Children[0];
    ViewBag.Title = titleNode.Data;
}
@section head 
{
    @Styles.Render("~/Content/fields.css")
    @Styles.Render("~/Content/treeview/jquery.treeview.css")
    @Scripts.Render("~/Scripts/jquery.cookie.js")
    @Scripts.Render("~/Scripts/jquery.treeview.js")
}
<div id="navtree">
    <input id="currentpath" type="hidden" value="@Model.EquationPath" />
    <h2 class="field-title">@titleNode.Data</h2>
    <ul id="treeview" class="treeview-red">
        @Html.Partial("~/Views/Shared/_FieldCategory.cshtml", titleNode.Children[0])
    </ul>
</div>
<div id="maincontent">
    <section id="equation">
    @if (!string.IsNullOrEmpty(Model.EquationName))
    {   
        <h1>@Model.EquationName</h1>
        <p>@Model.EquationDescription</p>
        <p>@Model.EquationFormula</p>
        <p><a href="@Context.Request.Url">
            <script>
                document.writeln(window.location);
            </script></a>
        </p>
        <p>@Model.EquationReference</p>
    }
    else
    {
        <p>Select an equation to display here.</p>
    }
    </section>
</div>

@section scripts
{
    <script type="text/javascript">
        $(document).ready(function () {
            var tree = $("#treeview").treeview({ collapsed: true });
            var currpath = $("#currentpath").val().split("/");
            
            currpath.forEach(function (entry) {
                $("span:contains('" + entry + "')").prev().click();
            });

        });
    </script>
}
